package com.education.teach.mvp.ui.adapter;

import android.content.Context;
import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.education.teach.R;
import com.education.teach.mvp.model.bean.CoursewareBean;

import java.util.List;

import dn.easy.common.constant.Contans;

public class CoursewareAdapter extends BaseQuickAdapter<CoursewareBean.ResultBean.QueryListBean, BaseViewHolder> {
    Context context;

    public CoursewareAdapter(int layoutResId, @Nullable List<CoursewareBean.ResultBean.QueryListBean> data, Context context) {
        super(layoutResId, data);
        this.context = context;
    }

    @Override
    protected void convert(BaseViewHolder helper, CoursewareBean.ResultBean.QueryListBean item) {
        RequestOptions options = new RequestOptions()
                .error(R.mipmap.icon_logo)
                .centerCrop();
        Glide.with(context)
                .load(Contans.BASE_IMG_URL + item.getPhoto())
                .apply(options)
                .into((ImageView) helper.getView(R.id.iv_new_img));
        helper.setText(R.id.tv_new_title, item.getDocumentName())
                .setText(R.id.tv_new_date,"作者:"+item.getJiaoShiName())
//                .setText(R.id.tv_new_date, TimeUtil.formatData(TimeUtil.dateFormatYMDofChinese, item.getCreateDate()))
                .addOnClickListener(R.id.btn_down);
    }
}
